package com.mingqijia.gassafety.console.controller.inner;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.webserver.request.inner.report.AlarmDataRequest;
import com.mingqijia.gassafety.webserver.request.inner.report.DeviceDataRequest;
import com.mingqijia.gassafety.webserver.response.inner.report.AlarmDataResponse;
import com.mingqijia.gassafety.webserver.response.inner.report.DeviceDataResponse;
import com.mingqijia.gassafety.webserver.service.report.ReportDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Slf4j
@Api(tags = "企业数据查询")
@RestController(value = "ReportDataController")
@RequestMapping("/inner/v1/sp/")
public class ReportDataController {

    @Autowired
    ReportDataService reportDataService;

    @PostMapping("/device/data")
    @ApiOperation(value = "设备数据")
    public CommonResponse<PageUtil<DeviceDataResponse>> deviceData(@RequestBody @Valid DeviceDataRequest request) {
        PageUtil<DeviceDataResponse> result = reportDataService.getDeviceData(request);
        return CommonResponse.success(result);
    }


    @PostMapping("/alarm/data")
    @ApiOperation(value = "设备告警处理数据")
    public CommonResponse<PageUtil<AlarmDataResponse>> alarmData(@RequestBody @Valid AlarmDataRequest request) {
        PageUtil<AlarmDataResponse> result = reportDataService.getAlarmData(request);
        return CommonResponse.success(result);
    }


}
